import { _decorator, Component, Node, tween, UIOpacity, UITransform, v3, Vec3 } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('Fail')
export class Fail extends Component {
    
    @property(Node)
    full: Node = null!

    @property([Node])
    fulls1: Node[] = []

    @property([Node])
    fulls2: Node[] = []

    show(then?: () => void) {
        tween(this)
            .call(() => {
                this.full.getComponent(UIOpacity).opacity = 0
                let scale: Vec3 = v3(1, 0, 1)
                for (let i = 0; i < this.fulls1.length; i++) {
                    let en: Node = this.fulls1[i]
                    en.scale = scale
                }
                for (let i = 0; i < this.fulls2.length; i++) {
                    let en: Node = this.fulls2[i]
                    en.scale = scale
                }
            })
            .delay(.5)
            .call(() => {
                tween(this.full.getComponent(UIOpacity))
                    .to(1, { opacity: 255 })
                    .start()
                let scale: Vec3 = v3(1, 1, 1)
                for (let i = 0; i < this.fulls1.length; i++) {
                    let en: Node = this.fulls1[i]
                    tween(en)
                        .to(1, { scale: scale })
                        .start()
                }
                for (let i = 0; i < this.fulls2.length; i++) {
                    let en: Node = this.fulls2[i]
                    tween(en)
                        .to(1, { scale: scale })
                        .start()
                }
            })
            .delay(1.5)
            .call(() => {
                if (then) {
                    then()
                }
            })
            .start()
    }
}


